getSymbolNames <- function(exchange) {
  con <- connectToVadb() 
  sql <- sprintf ("SELECT distinct stockname.code
         FROM stockname JOIN exchange ON (stockname.exchange_id= exchange.id)
         WHERE exchange.name='%s' ORDER BY stockname.code", exchange)
  fr <- dbGetQuery(con, sql)
  dbDisconnect(con)
  return (fr)
}

getSymbolNames.wikifolio <- function(excludeTrickySplits=FALSE) {
  con <- connectToVadb(dbname="va_wikifolio")
  if (excludeTrickySplits == TRUE) {
    dd <- "WHERE trickySplit IS NULL"
  } else {
    dd <- ""
  }
  sql <- sprintf("SELECT * FROM stockname %s ORDER BY symbol", dd)
  fr <- dbGetQuery(con, sql)
  dbDisconnect(con)
  return (fr)
}

getSymbolNames.wikifolio.DividendPayer <- function(excludeTrickySplits=FALSE) {
  con <- connectToVadb(dbname="va_wikifolio") 
  sql <- "SELECT DISTINCT id, symbol FROM dividends JOIN stockname ON (stockname.id = stock_id)"
  if (excludeTrickySplits==TRUE) {
    sql <- paste(sql, "WHERE trickySplit IS NULL")
  }
  sql <- paste(sql, "ORDER BY symbol")
  fr <- dbGetQuery(con, sql)
  dbDisconnect(con)
  return (fr) 
}